package com.bot.nft.module.op.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bot.common.pojo.CommonResult;
import com.bot.nft.module.op.domain.bo.OpAirListBo;
import com.bot.nft.module.op.domain.bo.OpAirListQueryBo;
import com.bot.nft.module.op.domain.vo.OpAirListVo;
import com.bot.nft.module.op.service.IOpAirListService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 空投活动白名单前端控制器
 * </p>
 *
 * @author zhangkaige
 * @since 2024-01-24
 */
@RestController
@RequestMapping("/airList")
public class OpAirListController {
    @Resource
    IOpAirListService airListService;


    //执行活动快照
    @GetMapping("/{airId}/snapshot.do")
    public CommonResult<Boolean> exeAirSna(@PathVariable String airId) {
        Boolean flag = airListService.gneAirList(airId);
        return flag ? CommonResult.ok() : CommonResult.error();
    }

    //分页查询空投白名单
    @RequestMapping("/{pageNo}/{pageSize}/pageAirList.do")
    public CommonResult<Page<OpAirListVo>> getAirList(@RequestBody OpAirListQueryBo airListQueryBo,
                                                      @PathVariable Integer pageNo, @PathVariable Integer pageSize) {
        Page<OpAirListVo> airInfoVoPage = airListService.getAirListPage(pageNo, pageSize, airListQueryBo.getAirId(),
                airListQueryBo.getPhone());
        return CommonResult.data(airInfoVoPage);
    }

    //添加空投活动白名单
    @PostMapping("/addAirList.do")
    public CommonResult<Boolean> addAirList(@RequestBody @Valid OpAirListBo airListBo) {
        Boolean flag = airListService.addAirList(airListBo);

        return flag ? CommonResult.ok() : CommonResult.error();
    }

    //删除空投活动白名单
    @GetMapping("/{airListId}/deleteAirList.do")
    public CommonResult<Boolean> deleteAirList(@PathVariable String airListId) {
        Boolean flag = airListService.delAirListById(airListId);

        return flag ? CommonResult.ok() : CommonResult.error();
    }
}
